baseDirForScriptSelf=$(cd "$(dirname "$0")"; pwd)
cd $baseDirForScriptSelf

log_filename=$(date +%F).log
docker-compose up > ./logs/$log_filename &
sleep 15s

qboss_installed=$(mysql -h127.0.0.1 -P3307 -uroot -proot -e 'show databases;' | grep qboss)
if [ -z "$qboss_installed" ]; then 
	echo 'install databases'
	mysql -h127.0.0.1 -P3307 -uroot -proot -e 'create database qboss;'
	mysql -h127.0.0.1 -P3307 -uroot -proot qboss < $baseDirForScriptSelf/uploads/install.sql
fi
echo 'update databases'
mysql -h127.0.0.1 -P3307 -uroot -proot -f qboss < $baseDirForScriptSelf/uploads/update.sql
